var ns, map, app, timer, marqueesHeight, slide, imageBrowser,
    stopscroll, scrollElem, preTop, currentTop, stoptime, leftElem, popup;
app = new Vue({
    el: '#app',
    data: {
        ID:0,
        ProjectID:0,
        form: {
            status: 1,//1-待接单 2-处理中 3-已完工 4-已关单
        },
        list: [], 
        isviewhistory: false,
        IsHistory: 0,//0 列表 1 历史工单
        IsActive:false,
        UseStatus:0,
    },
    methods: {
        get_data: function() {
            var that = this;
            var options = {};
            options.ID = that.ID;
            options.action = "getinspectionitems"; 
            ns.post(options, function (succeed, data, err) {
                if (succeed) {
                    if(data.status){
                        that.list = data.data;
                        that.IsActive=data.IsActive;
                    }
                    
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
                // setTimeout(()=>{
                    api.sendEvent({
                        name:'is_hidden_right_control_list',
                        extra: {
                            keyId: "right_controlrenwu",
                            IsHidden: that.IsActive
                        }
                    })
                // },500)
            }, {
                toast: true
            });
        },
        //检查记录
        do_jiancha:function(Item2){
            var that=this;
            if(that.UseStatus==2){
                api.toast({
                    msg: '当前任务已过期，不能进行检查操作',
                    duration: 2000,
                    location: 'bottom'
                });
                return;
            }
            if(Item2.Status==3){
                ns.openWin('qualityjianhca_over', '检查记录',{
                    ID:Item2.ID
                });
            }else{
                ns.openWin('qualityrecord', '检查记录',{
                    CheckpointsID:Item2.CheckpointsID,
                    ID:Item2.ID,
                    PointID:Item2.PointID
                })
            }
        },
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.ID = api.pageParam.ID||0;
    app.ProjectID = api.pageParam.ProjectID||0;
    app.UseStatus = api.pageParam.UseStatus||0;
    app.get_data();
    api.addEventListener({
        name: 'loadservicelist'
    }, function(ret, err) {
        app.get_data();
    });
    api.addEventListener({
        name: 'close_window'
    }, function(ret, err) {
        api.closeWin();
    });
    

    api.addEventListener({
        name: 'do_open_controlreact'
    }, function (ret, err) {
        ns.openWin('quality_chooseperson','选择转交人',{
            id:app.ID,
            ProjectID:app.ProjectID,
            type:4,
        });
    });

};
